import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginVue from "eslint-plugin-vue";


/** @type {import('eslint').Linter.Config[]} */
export default [
	{
		files: ["**/*.{js,mjs,cjs,ts,vue}"]
	},
	{
		languageOptions: {
			globals: {
				...globals.browser,
				...globals.node
			}
		}
	},
	pluginJs.configs.recommended,
	...tseslint.configs.recommended,
	...pluginVue.configs["flat/essential"],
	{
		files: ["**/*.vue"],
		languageOptions: {
			parserOptions: {
				parser: tseslint.parser
			}
		}
	},
	{
		rules: {
			"semi": ["error", "always"],
			"no-var": "error",
			"no-empty": ["error", {"allowEmptyCatch": true}],
			"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
			// vue 相关
			"vue/multi-word-component-names": "off", // 禁止组件名称必须是多个单词
			"vue/no-unused-components": "error", // 禁止未使用的组件
			"vue/html-closing-bracket-newline": ["error", { "singleline": "never", "multiline": "never" }], // 指定 HTML 标签的闭合括号是否需要换行
			"vue/html-closing-bracket-spacing": ["error", { "startTag": "never", "endTag": "never" }],
			"@typescript-eslint/no-explicit-any": "off"
		}
	}
];
